home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 11 - 1995 / 11.02 Feb 95 / Yenta / Erics C++ Libraries / Interface Classes / CPPTEWindow.cp < prev    next >
Encoding:
Text File  |  1996-04-04  |  4.6 KB  |  151 lines  |  [TEXT/KAHL]

  1. /***************************************************** IMPLEMENTATION
  2.     DATE:    9/21/93
  3.     AUTHOR: Eric R. Rosé
  4.  
  5.     CLASS:  CPPTextWindow
  6.     
  7.     SUPERCLASS: CPPWindow, CPPText
  8.     
  9.         This C++ class manages a text editing window
  10.     
  11. ********************************************************************/
  12.  
  13. #include <CPPTEWindow.h>
  14. #include <Commands.h>
  15. #include <MathTools.h>
  16.  
  17. /*-----------------------------------------------------------------*/
  18. /*------------------------ PUBLIC METHODS -------------------------*/
  19. /*-----------------------------------------------------------------*/
  20.  
  21.     CPPTEWindow::CPPTEWindow (CPPWindowManager *theManager, int ResID, 
  22.                               Boolean HScroll, Boolean VScroll,
  23.                               int Font, int FSize) :
  24.                 CPPWindow (theManager, ResID),
  25.                 CPPFilterText ((CPPWindow *)this, 32767, HScroll, VScroll,
  26.                                pass, (int)all, Font, FSize)
  27.     /* most of the work is done in the initialization phase */
  28.     {
  29.         SetMinMaxSize(70, 70, kPageWidth + kSBarWidth,
  30.                          kPageHeight + kSBarWidth);
  31.         SetMinSize (70, 70);
  32.         SetMaxSize (kPageWidth + kSBarWidth, kPageHeight + kSBarWidth);
  33.     }
  34.                          
  35. /*-----------------------------------------------------------------*/
  36.                      
  37.     CPPTEWindow::CPPTEWindow (CPPWindowManager *theManager,
  38.                               Rect *bounds, StringPtr title, Boolean isVisible,
  39.                               int windowKind, Boolean hasGoAway, int RefCon,
  40.                               Boolean HScroll, Boolean VScroll,
  41.                               int Font, int FSize) :
  42.                  CPPWindow (theManager, bounds, title, isVisible,
  43.                              windowKind, hasGoAway, RefCon),
  44.                  CPPFilterText ((CPPWindow *)this, 32767, HScroll, VScroll,
  45.                                  pass, (int)all, Font, FSize)
  46.     /* most of the work is done in the initialization phase */
  47.     {
  48.         SetMinMaxSize(70, 70, kPageWidth + kSBarWidth,
  49.                          kPageHeight + kSBarWidth);
  50.         SetMinSize (70, 70);
  51.         SetMaxSize (kPageWidth + kSBarWidth, kPageHeight + kSBarWidth);
  52.     }
  53.  
  54. /*-----------------------------------------------------------------*/
  55.  
  56.     CPPTEWindow::~CPPTEWindow (void)
  57.     {
  58.     
  59.     }
  60.  
  61. /*-----------------------------------------------------------------*/
  62.  
  63.     char    *CPPTEWindow::ClassName (void)
  64.     {
  65.         return "CPPTEWindow";
  66.     }
  67.  
  68. /*-----------------------------------------------------------------*/
  69.  
  70.     Boolean    CPPTEWindow::DoCommand (short commandID)
  71.     /* the default method sends the command to the target of the */
  72.     /* window. */
  73.     /* SUBCLASS SHOULD OVERRIDE */
  74.     {
  75.         return CPPFilterText::DoCommand(commandID);
  76.     }
  77.  
  78. /*-----------------------------------------------------------------*/
  79. /*---------------------- PROTECTED METHODS ------------------------*/
  80. /*-----------------------------------------------------------------*/
  81.  
  82.     void    CPPTEWindow::Activate (void)
  83.     /* do the necessary bookkeeping to keep track of the window's state */
  84.     {
  85.         CPPWindow::Activate();
  86.         
  87.         if (this->theWindow)
  88.           this->WisActive = TRUE;
  89.     }
  90.             
  91. /*-----------------------------------------------------------------*/
  92.  
  93.     void    CPPTEWindow::Deactivate (void)
  94.     /* do the necessary bookkeeping to keep track of the window's state */
  95.     {
  96.         if (this->theWindow)
  97.             this->WisActive = FALSE;
  98.     }
  99.  
  100. /*-----------------------------------------------------------------*/
  101.     
  102.     void    CPPTEWindow::DoUserClick (EventRecord *theEvent)
  103.     /* instance specific handler for clicking in the window */
  104.     /* SUBCLASS SHOULD OVERRIDE */
  105.     {
  106.         CPPText::DoClick (theEvent);    // textedit object method
  107.     }
  108.  
  109. /*-----------------------------------------------------------------*/
  110.  
  111.     void    CPPTEWindow::DoUserUpdate (void)
  112.     /* instance specific handler for drawing the window's contents */
  113.     /* SUBCLASS SHOULD OVERRIDE */
  114.     {
  115.         this->Draw();    // textedit object method
  116.     }
  117.  
  118. /*-----------------------------------------------------------------*/
  119.  
  120.     void    CPPTEWindow::DoUserIdle (void)
  121.     /* instance specific handler for idling when the window is */
  122.     /* the frontmost window */
  123.     /* SUBCLASS SHOULD OVERRIDE */
  124.     {
  125.         if (this->TextBlock && this->WisActive)
  126.           CPPText::DoIdle();    // textedit object method
  127.     }
  128.  
  129. /*-----------------------------------------------------------------*/
  130.  
  131.     Boolean    CPPTEWindow::DoUserKey (EventRecord *theEvent)
  132.     /* instance specific handler for handling a keypress */
  133.     /* return TRUE if we handled the key, FALSE otherwise */
  134.     /* SUBCLASS SHOULD OVERRIDE */
  135.     {
  136.         char theKey;
  137.  
  138.         theKey = theEvent->message & charCodeMask;
  139.         return this->DoKey(theKey, theEvent->modifiers, theEvent->what);
  140.     }
  141.  
  142. /*-----------------------------------------------------------------*/
  143.  
  144.     void    CPPTEWindow::DoUserChangeSize (short newWidth, short newHeight)
  145.     /* instance specific handler for resizing the window; use this */
  146.     /* opportunity to change the size of the scrollbars and TE area */
  147.     {
  148.         CPPText::Resize (newWidth, newHeight);    // textedit object method
  149.     }
  150.  
  151.